package com.wfl.sampling.web;

import com.wfl.sampling.entity.GroupChatDo;
import com.wfl.sampling.entity.GroupMessageDo;
import com.wfl.sampling.entity.ShadowDo;
import com.wfl.sampling.entity.UserMessageDo;
import com.wfl.sampling.service.GroupChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController
@RequestMapping("/api/group")
public class GroupChatController {
    @Autowired
    private GroupChatService groupChatService;
    //创建群聊
    @PostMapping ("/create")
    public String createGroupChat(@RequestBody GroupChatDo groupChatDo){
        return groupChatService.createGroupChat(groupChatDo);
    }
    //查询群消息记录  传入群id
    @GetMapping("/getGroupMessage")
    public ArrayList<GroupMessageDo> getUserMessage(@RequestParam(name = "groupId") Integer groupId){
        return groupChatService.getGroupMessage(groupId);
    }
    //保存对话消息  传入用户id  群聊id   消息
    @PostMapping("/saveConversion")
    public String saveConversionMessage(@RequestParam(name = "userId") Integer userId,
                                        @RequestParam(name = "groupId") Integer groupId,
                                        @RequestParam(name = "message") String message){
        return groupChatService.saveConversionMessage(userId,groupId,message);
    }
}
